import Vue from "vue";
import Router from "vue-router";
import Apis from "@/apis";

// 懒加载路由并命名 chunk 文件
const Login = () => import("@/pages/login");
const Signup = () => import("@/pages/signup");
const Main = () => import("@/pages/main");
const Home = () => import("@/pages/home/home");

// 个人中心
const personalCenter = () => import("@/pages/personalCenter");

//配置业务
const applist = () => import("@/pages/admin/application/applist");
// //设备信息
// const panoramaPoint = () => import("@/pages/admin/panoramaPoint/panoramaPoint");
// //测点配置
// const empowerlist = () => import("@/pages/admin/empower/empowerlist");
// //监控分析
// const monitoringAnalysis = () =>
//   import("@/pages/admin/monitoringAnalysis/monitoringAnalysis");
//设备配置
const pointConfig = () => import("@/pages/admin/pointConfig/pointConfig");
//全景配置
const panoramaConfig = () => import("@/pages/admin/panoramaConfig/panoramaConfig");
//监控配置
const monitorConfig = () => import("@/pages/admin/monitorConfig/monitorConfig");
// //监测站点配置
// const siteConfig = () => import("@/pages/admin/siteConfig/siteConfig");

// ----------------
// 设备分类
const equipmentClassify = () => import("@/pages/admin/equipmentClassify/equipmentClassify");
// 设备台账
const equipmentAccount = () =>
  import("@/pages/admin/equipmentAccount/equipmentAccount");

const equipmentAccountAdd = () =>
  import("@/pages/admin/equipmentAccount/equipmentAccountAdd");
const equipmentAccountDetial = () =>
  import("@/pages/admin/equipmentAccount/equipmentAccountDetial");

// // 站点类型管理
// const siteType = () => import("@/pages/admin/siteType/siteType");
// const siteTypeAdd = () => import("@/pages/admin/siteType/siteTypeAdd");
// const siteTypeDetial = () => import("@/pages/admin/siteType/siteTypeDetial");
// // 监测站点
// const monitorsiteManage = () =>
// 	import("@/pages/admin/monitorsiteManage/monitorsiteManage");
// const monitorsiteAdd = () =>
// 	import("@/pages/admin/monitorsiteManage/monitorsiteAdd");
// const monitorsiteDetial = () =>
// 	import("@/pages/admin/monitorsiteManage/monitorsiteDetial");
// 全景图管理
const panoramaManage = () =>
  import("@/pages/admin/panoramaManage/panoramaManage");
const panoramaAddTwo = () =>
  import("@/pages/admin/panoramaManage/panoramaAddTwo");
const panoramaDetial = () =>
  import("@/pages/admin/panoramaManage/panoramaDetial");

// // 工程管理
// const introduce = () => import("@/pages/admin/introduce/introduce");
// // 工程管理新增
// const introduceAdd = () => import("@/pages/admin/introduce/introduceAdd");
// // 气泡管理
// const bubble = () => import("@/pages/admin/bubbleManage/bubble");
// 3d模型
const modelMassage = () =>
  import("@/pages/admin/equipmentAccount/modelMassage");

// 版本管理
const versionManage = () => import("@/pages/admin/versionManage/versionManage");
// 模型文件管理
const modelFileManage = () =>
  import("@/pages/admin/modelFileManage/modelFileManage");
const modelFilePronList = () =>
  import("@/pages/admin/modelFileManage/modelFilePronList");
const modelFileAdd = () => import("@/pages/admin/modelFileManage/modelFileAdd");
// 模型配置管理
const modelConfigurationManage = () =>
  import("@/pages/admin/modelConfigurationManage/modelConfigurationManage");
const modelConfigurationAdd = () =>
  import("@/pages/admin/modelConfigurationManage/modelConfigurationAdd");
// // 地区高亮坐标管理
// const highlightCoordinateManage = () =>
// 	import("@/pages/admin/highlightCoordinateManage/highlightCoordinateManage");
// const highlightCoordinateAdd = () =>
// 	import("@/pages/admin/highlightCoordinateManage/highlightCoordinateAdd");
// 图标管理
const iconMessage = () =>
  import("@/pages/admin/iconMessage/iconMessage");
const iconAdd = () =>
  import("@/pages/admin/iconMessage/iconAdd");

export const admin = {
  path: "/root",
  component: Main,
  children: [
    {
      title: "配置业务",
      icon: "el-icon-menu",
      isMenu: true,
      path: "/admin/application/applist",
      component: applist
    },
    // {
    //   title: "监测分析",
    //   icon: "el-icon-setting",
    //   isMenu: true,
    //   path: "/admin/monitor/list",
    //   component: () => import("@/pages/admin/monitor/list")
    // },
    // {
    //   title: "添加分组",
    //   icon: "el-icon-setting",
    //   isMenu: false,
    //   path: "/admin/monitor/add",
    //   component: () => import("@/pages/admin/monitor/add")
    // },
    // {
    //   title: "测点列表",
    //   icon: "el-icon-setting",
    //   isMenu: false,
    //   path: "/admin/monitor/group",
    //   component: () => import("@/pages/admin/monitor/group")
    // },
    // {
    //   title: "更新配置",
    //   icon: "el-icon-setting",
    //   isMenu: false,
    //   path: "/admin/monitor/add_device",
    //   component: () => import("@/pages/admin/monitor/addDevice")
    // },
    // {
    //   title: "设备管理",
    //   name: "equipmentAccount",
    //   icon: "el-icon-files",
    //   isMenu: true,
    //   path: "/admin/equipmentAccount/equipmentAccount",
    //   component: equipmentAccount,
    //   subLevel: [
    //     // {
    //     //   title: "设备类型",
    //     //   name: "equipmentClassify",
    //     //   icon: "el-icon-c-scale-to-original",
    //     //   isMenu: true,
    //     //   path: "/admin/equipmentClassify/equipmentClassify",
    //     //   component: equipmentClassify
    //     // },
    //     {
    //       title: "设备列表",
    //       name: "equipmentAccount",
    //       icon: "el-icon-files",
    //       isMenu: true,
    //       path: "/admin/equipmentAccount/equipmentAccount",
    //       component: equipmentAccount
    //     },
    //     {
    //       title: "设备配置",
    //       name: "pointConfig",
    //       icon: "el-icon-s-operation",
    //       isMenu: true,
    //       path: "/admin/pointConfig/pointConfig",
    //       component: pointConfig
    //     },
    //     {
    //       title: "监控配置",
    //       name: "monitorConfig",
    //       icon: "el-icon-video-camera",
    //       isMenu: true,
    //       path: "/admin/monitorConfig/monitorConfig",
    //       component: monitorConfig
    //     },
    //   ]
    // },
    // // {
    // // 	title: "站点管理",
    // // 	name: "siteType",
    // // 	icon: "el-icon-c-scale-to-original",
    // // 	isMenu: true,
    // // 	path: "/admin/siteType/siteType",
    // // 	component: siteType,
    // // 	subLevel: [{
    // // 			title: "站点类型",
    // // 			icon: "el-icon-c-scale-to-original",
    // // 			isMenu: true,
    // // 			path: "/admin/siteType/siteType",
    // // 			component: siteType
    // // 		},
    // // 		{
    // // 			title: "监测站点",
    // // 			icon: "el-icon-c-scale-to-original",
    // // 			isMenu: true,
    // // 			path: "/admin/monitorsiteManage/monitorsiteManage",
    // // 			component: monitorsiteManage
    // // 		}
    // // 	]
    // // },
    // {
    //   title: "全景管理",
    //   icon: "el-icon-video-camera",
    //   isMenu: true,
    //   path: "/admin/panoramaManage/panoramaManage",
    //   component: panoramaManage,
    //   subLevel: [{
    //     title: "全景管理",
    //     icon: "el-icon-video-camera",
    //     isMenu: true,
    //     path: "/admin/panoramaManage/panoramaManage",
    //     component: panoramaManage
    //   },
    //     {
    //       title: "全景配置",
    //       icon: "el-icon-picture-outline-round",
    //       isMenu: true,
    //       path: "/admin/panoramaConfig/panoramaConfig",
    //       component: panoramaConfig
    //     }
    //   ]
    // },
    // {
    // 	title: "工程管理",
    // 	icon: "el-icon-s-opportunity",
    // 	isMenu: true,
    // 	path: "/admin/introduce/introduce",
    // 	component: introduce
    // },
    // {
    // 	title: "气泡管理",
    // 	icon: "el-icon-s-help",
    // 	isMenu: true,
    // 	path: "/admin/bubbleManage/bubble",
    // 	component: bubble
    // },
    // {
    //   title: "图标管理",
    //   icon: "el-icon-aim",
    //   isMenu: true,
    //   path: "/admin/iconMessage/iconMessage",
    //   component: iconMessage
    // },
    // {
    //   title: "模型管理",
    //   icon: "el-icon-open",
    //   isMenu: true,
    //   path: "/admin/modelFileManage/modelFileManage",
    //   component: modelFileManage,
    //   subLevel: [
    //     {
    //       title: "模型文件管理",
    //       icon: "el-icon-s-cooperation",
    //       isMenu: true,
    //       path: "/admin/modelFileManage/modelFileManage",
    //       component: modelFileManage
    //     },
    //     // {
    //     //   title: "版本管理",
    //     //   icon: "el-icon-open",
    //     //   isMenu: true,
    //     //   path: "/admin/versionManage/versionManage",
    //     //   component: versionManage
    //     // },
    //     {
    //       title: "模型配置管理",
    //       icon: "el-icon-s-unfold",
    //       isMenu: true,
    //       path: "/admin/modelConfigurationManage/modelConfigurationManage",
    //       component: modelConfigurationManage
    //     },
    //   ],
    // },


    // {
    // 	title: "地区高亮坐标管理",
    // 	icon: "el-icon-star-off",
    // 	isMenu: true,
    // 	path: "/admin/highlightCoordinateManage/highlightCoordinateManage",
    // 	component: highlightCoordinateManage
    // },

    {
      title: "设备台账新增修改",
      icon: "el-icon-files",
      isMenu: false,
      path: "/admin/equipmentAccount/equipmentAccountAdd",
      component: equipmentAccountAdd
    },
    {
      title: "设备台账详情",
      icon: "el-icon-files",
      isMenu: false,
      path: "/admin/equipmentAccount/equipmentAccountDetial",
      component: equipmentAccountDetial
    },
    {
      title: "3d模型管理",
      icon: "el-icon-files",
      isMenu: false,
      path: "/admin/equipmentAccount/modelMassage",
      component: modelMassage
    },
    // {
    //   title: "设备类型",
    //   icon: "el-icon-c-scale-to-original",
    //   isMenu: false,
    //   path: "/admin/equipmentClassify/equipmentClassify",
    //   component: equipmentClassify
    // },
    {
      title: "设备列表",
      icon: "el-icon-files",
      isMenu: false,
      path: "/admin/equipmentAccount/equipmentAccount",
      component: equipmentAccount
    },
    {
      title: "测点列表",
      icon: "el-icon-files",
      isMenu: false,
      path: "/admin/equipmentAccount/measurePointList",
      component: () => import("@/pages/admin/equipmentAccount/measurePointList")
    },
    {
      title: "添加测点",
      icon: "el-icon-files",
      isMenu: false,
      path: "/admin/equipmentAccount/measurePointAdd",
      component: () => import("@/pages/admin/equipmentAccount/measurePointAdd")
    },
    // {
    // 	title: "站点类型",
    // 	icon: "el-icon-c-scale-to-original",
    // 	isMenu: false,
    // 	path: "/admin/siteType/siteType",
    // 	component: siteType
    // },
    // {
    // 	title: "站点类型新增",
    // 	icon: "el-icon-c-scale-to-original",
    // 	isMenu: false,
    // 	path: "/admin/siteType/siteTypeAdd",
    // 	component: siteTypeAdd
    // },
    // {
    // 	title: "站点类型详情",
    // 	icon: "el-icon-c-scale-to-original",
    // 	isMenu: false,
    // 	path: "/admin/siteType/siteTypeDetial",
    // 	component: siteTypeDetial
    // },
    // {
    // 	title: "监测站点",
    // 	icon: "el-icon-c-scale-to-original",
    // 	isMenu: false,
    // 	path: "/admin/monitorsiteManage/monitorsiteManage",
    // 	component: monitorsiteManage
    // },
    // {
    // 	title: "监测站点新增",
    // 	icon: "el-icon-c-scale-to-original",
    // 	isMenu: false,
    // 	path: "/admin/monitorsiteManage/monitorsiteAdd",
    // 	component: monitorsiteAdd
    // },
    // {
    // 	title: "监测站点详情",
    // 	icon: "el-icon-c-scale-to-original",
    // 	isMenu: false,
    // 	path: "/admin/monitorsiteManage/monitorsiteDetial",
    // 	component: monitorsiteDetial
    // },
    {
      title: "全景图新增",
      icon: "el-icon-c-scale-to-original",
      isMenu: false,
      path: "/admin/panoramaManage/panoramaAddTwo",
      component: panoramaAddTwo
    },
    {
      title: "全景图详情",
      icon: "el-icon-c-scale-to-original",
      isMenu: false,
      path: "/admin/panoramaManage/panoramaDetial",
      component: panoramaDetial
    },
    {
      title: "模型文件详细列表",
      icon: "el-icon-s-cooperation",
      isMenu: false,
      path: "/admin/modelFileManage/modelFilePronList",
      component: modelFilePronList
    },
    {
      title: "模型文件新增修改",
      icon: "el-icon-s-cooperation",
      isMenu: false,
      path: "/admin/modelFileManage/modelFileAdd",
      component: modelFileAdd
    },
    {
      title: "模型配置新增修改",
      icon: "el-icon-s-unfold",
      isMenu: false,
      path: "/admin/modelConfigurationManage/modelConfigurationAdd",
      component: modelConfigurationAdd
    },
    // {
    // 	title: "地区高亮坐标新增修改",
    // 	icon: "el-icon-star-off",
    // 	isMenu: false,
    // 	path: "/admin/highlightCoordinateManage/highlightCoordinateAdd",
    // 	component: highlightCoordinateAdd
    // },
    {
      title: "图标管理",
      icon: "el-icon-star-off",
      isMenu: false,
      path: "/admin/iconMessage/iconMessage",
      component: iconMessage
    },
    {
      title: "图标管理新增",
      icon: "el-icon-star-off",
      isMenu: false,
      path: "/admin/iconMessage/iconAdd",
      component: iconAdd
    },
    // {
    // 	title: "工程管理新增",
    // 	icon: "el-icon-star-off",
    // 	isMenu: false,
    // 	path: "/admin/introduce/introduceAdd",
    // 	component: introduceAdd
    // }

    {
      title: "设备配置",
      name: "pointConfig",
      icon: "el-icon-s-operation",
      isMenu: false,
      path: "/admin/pointConfig/pointConfig",
      component: pointConfig
    },
    {
      title: "监控配置",
      name: "monitorConfig",
      icon: "el-icon-video-camera",
      isMenu: false,
      path: "/admin/monitorConfig/monitorConfig",
      component: monitorConfig
    },
    {
      title: "版本管理",
      icon: "el-icon-open",
      isMenu: false,
      path: "/admin/versionManage/versionManage",
      component: versionManage
    },
    {
      title: "模型配置管理",
      icon: "el-icon-s-unfold",
      isMenu: false,
      path: "/admin/modelConfigurationManage/modelConfigurationManage",
      component: modelConfigurationManage
    },
    {
      title: "全景配置",
      icon: "el-icon-picture-outline-round",
      isMenu: false,
      path: "/admin/panoramaConfig/panoramaConfig",
      component: panoramaConfig
    }
  ]
};

// noinspection JSAnnotator
export const constantRouterMap = [{
  path: "/",
  redirect: "login"
},
  {
    path: "/login",
    component: Login
  },
  {
    path: "/signup",
    component: Signup
  },
  {
    path: "/",
    component: Main,
    children: [{
      path: "/home",
      component: Home
    },
      {
        path: "/personal-center",
        component: personalCenter
      }
    ]
  },
  // 管理
  admin
];

Vue.use(Router);
const router = new Router({
  // 使用h5模式
  // mode: 'history',
  mode: 'history',
  routes: constantRouterMap
});
router.beforeEach((to, from, next) => {
  // 获取权限名称  路由切换后判断当前路由地址是否存在 权限名称
  // 登录控制逻辑，根据项目不同做修改
  let user = false;
  if (sessionStorage.getItem(Apis.getLocalKey().user)) {
    user = JSON.parse(sessionStorage.getItem(Apis.getLocalKey().user));
  }

  // 存路径
  sessionStorage.setItem("to_path", to.path);
  if (to.path !== "/login" && to.path !== "/signup" && !user) {
    next({
      path: "/"
    });
  } else {
    next();
  }

  // let user = false;
  // if (sessionStorage.getItem(Apis.getLocalKey().user)) {
  //   user = JSON.parse(sessionStorage.getItem(Apis.getLocalKey().user));
  // }
  // if (to.path !== "/login" && to.path !== "/signup" && !user) {
  //   next({
  //     path: "/"
  //   });
  // } else {
  //   next();
  // }
  // // next();
});

export default router;
